/**
 * 
 */
package entity;

import java.util.List;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * @author Chigco.Orc
 *
 */
@Entity
@Table(name="orders")
public class Order {
	private Long id;
	private User user;
	private List<Product> products;
	private int state;  		//订单状态 0  1 买家已付款 2 卖家已发货 
	
	@Id
	@GeneratedValue
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	/*
	 * 订单与用户的关系：多对一
	 */
	@ManyToOne
	@JoinColumn(name = "userId")
	public User getUser() {
		return user;
	}
	public void setUser(User user) {
		this.user = user;
	}
	/*
	 * 订单与商品的关系：一对多
	 */
	@OneToMany(mappedBy="order")
	public List<Product> getProducts() {
		return products;
	}
	public void setProducts(List<Product> products) {
		this.products = products;
	}
	
	public int getState() {
		return state;
	}
	public void setState(int state) {
		this.state = state;
	}
}
